#include "main/utils.h"
using namespace std;

int max(const vector<int>& vec) {
  int ret = vec[0];
  for (int i = 1; i < vec.size(); ++i) {
    if (vec[i] > ret) {
      ret = vec[i];
    }
  }
  return ret;
}

int getHours(const vector<int>& vec, const int& k) {
  int ret = 0;
  for (int i = 0; i < vec.size(); ++i) {
    // ret += vec[i] % k == 0 ? vec[i] / k : vec[i] / k + 1;
    ret += (vec[i] + k - 1) / k;
  }
  return ret;
}

int minEatSpeed(const vector<int>& vec, const int& hours) {
  int begin = 1;
  int end = max(vec);
  while (begin <= end) {
    int mid = (begin + end) / 2;
    if (getHours(vec, mid) <= hours) {
      if (mid == 1 || getHours(vec, mid - 1) > hours) {
        return mid;
      }
      end = mid - 1;
    } else {
      begin = mid + 1;
    }
  }
  return -1;
}

int main() {
  vector<int> vec = {3, 6, 7, 11};
  cout << minEatSpeed(vec, 8) << endl;

  return 0;
}
